<template>
  <el-row :gutter="20" class="panel-group">
    <el-col :xs="24" :sm="24" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('newVisitis')">
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon icon-class="home-user" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            今日注册用户
          </div>
          <count-to :start-val="0" :end-val="regtoday" :duration="2600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="24" :sm="24" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('newVisitis')">
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon icon-class="home-user" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            昨日注册用户
          </div>
          <count-to :start-val="0" :end-val="regyesday" :duration="2600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="24" :sm="24" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('messages')">
        <div class="card-panel-icon-wrapper icon-message">
          <svg-icon icon-class="sales" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            今日销售额
          </div>
          <count-to :start-val="0" :end-val="saletoday" :duration="3000" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="24" :sm="24" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('purchases')">
        <div class="card-panel-icon-wrapper icon-money">
          <svg-icon icon-class="sales" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            昨日销售额
          </div>
          <count-to :start-val="0" :end-val="saleyesday" :duration="3200" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="24" :sm="24" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('shoppings')">
        <div class="card-panel-icon-wrapper icon-shopping">
          <svg-icon icon-class="recharge" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            今日充值额
          </div>
          <count-to :start-val="0" :end-val="rechargetoday" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="24" :sm="24" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('shoppings')">
        <div class="card-panel-icon-wrapper icon-shopping">
          <svg-icon icon-class="recharge" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            昨日充值额
          </div>
          <count-to :start-val="0" :end-val="rechargeyesday" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import { getHomeInfo } from '@/api/home'

export default {
  data() {
    return{
      info:{},
      regtoday: 0,//"今日注册用户"
      regyesday: 0,//"昨日注册用户"
      rechargetoday: 0,//"今日用户充值额度"
      rechargeyesday: 0,//"昨日用户充值额度"
      saletoday: 0,//"今日销售额度"
      saleyesday: 0//"昨日销售额度"
    }
  },
  components: {
    CountTo
  },
  created() {
    this.getInfo()
  },
  methods: {
    handleSetLineChartData(type) {
      this.$emit('handleSetLineChartData', type)
    },
    getInfo() {
      getHomeInfo().then(res=>{
        console.log(res)
        this.regtoday = +(res.data.regtoday)
        this.regyesday = +(res.data.regyesday)
        this.rechargetoday = +(res.data.rechargetoday)/100
        this.rechargeyesday = +(res.data.rechargeyesday)/100
        this.saletoday = +(res.data.saletoday)/100
        this.saleyesday = +(res.data.saleyesday)/100
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: -18px;

  .card-panel-col {
    margin-bottom: 20px;
  }

  .card-panel {
    // height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    border: 1px solid #F1F0F0;
    border-radius: 3px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    // &:hover {
    //   .card-panel-icon-wrapper {
    //     color: #fff;
    //   }

    //   .icon-people {
    //     background: #40c9c6;
    //   }

    //   .icon-message {
    //     background: #36a3f7;
    //   }

    //   .icon-money {
    //     background: #f4516c;
    //   }

    //   .icon-shopping {
    //     background: #34bfa3
    //   }
    // }

    // .icon-people {
    //   color: #40c9c6;
    // }

    // .icon-message {
    //   color: #36a3f7;
    // }

    // .icon-money {
    //   color: #f4516c;
    // }

    // .icon-shopping {
    //   color: #34bfa3
    // }

    .card-panel-icon-wrapper {
      // float: left;
      width: 75px;
      height: 75px;
      // margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
      color: #E82F5F;
      background-color: #FFD5DA;
      border-radius: 16px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .card-panel-icon {
      // float: left;
      font-size: 38px;
    }

    .card-panel-description {
      // float: right;
      font-weight: bold;
      // margin: 26px;
      margin-left: 0px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      line-height: 30px;
      text-align: center;

      .card-panel-text {
        font-size: 16px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #666666;
      }

      .card-panel-num {
        font-size: 24px;
        font-family: HIU Golden Ratio Founder;
        font-weight: normal;
        color: #E82F5F;
      }
    }
  }
}

// @media (max-width:550px) {
//   // .card-panel-description {
//   //   display: none;
//   // }

//   .card-panel-icon-wrapper {
//     // float: none !important;
//     // width: 100%;
//     // height: 100%;
//     margin: 0 !important;

//     .svg-icon {
//       // display: block;
//       margin: 14px auto !important;
//       // float: none !important;
//     }
//   }
// }
</style>
